package demo2;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

public class Test {
    public static void main(String[] args) {
        int[] array = {11,23,11,5,4,3,5};
        Set<Integer> set = new TreeSet<>();
        for (int i = 0; i < array.length; i++) {
            set.add(array[i]);
        }
        for (Integer n: set) {
            System.out.print(n + " ");
        }
        System.out.println();
        Map<Integer,Integer> map = new TreeMap<>();
        for (int i = 0; i < array.length; i++) {
            if (map.containsKey(array[i])) {
                map.put(array[i],map.get(array[i]) + 1);
                //System.out.println(array[i]);
                //break;
            } else {
                map.put(array[i],1);
            }
        }
        System.out.println(map);
        System.out.println(map.entrySet());
        for (Map.Entry<Integer,Integer> entry: map.entrySet()) {
            if (entry.getValue() > 1) {
                System.out.print(entry.getKey() + " " + entry.getValue() + " ");
            }
        }
    }
}
